package com.base.action;

import java.io.File;
import java.util.List;

import com.base.bean.Cardinfo;
import com.base.bean.Cardmake;
import com.base.bean.Cardmaker;
import com.base.bean.Cardstuff;
import com.base.bean.Design;
import com.base.bean.Goodsman;
import com.base.service.CardTypeService;
import com.base.service.CardinfoService;
import com.base.service.CardmakeService;
import com.base.service.CardmakerService;
import com.base.service.CardstuffService;
import com.base.service.DepartmentService;
import com.base.service.DesignService;
import com.base.service.DictService;
import com.base.service.GoodsmanService;
import com.common.bean.Cardsubtype;
import com.common.bean.Datadict;
import com.common.bean.Department;
import com.common.util.PagerModel;
import com.common.util.StringToken;
import com.core.ssh2.AbstractActionSupport;
import com.opensymphony.xwork2.Preparable;

public class CardinfoManagerAction extends AbstractActionSupport implements Preparable{
	private static final long serialVersionUID = 346174986344121500L;

	private CardinfoService cardinfoService;
	
	private DictService dictService;
	
	private DepartmentService departmentService;
	
	private DesignService designService;
	
	private CardmakeService cardmakeService;
	
	private CardmakerService cardmakerService;
	
	private CardstuffService cardstuffService;
	
	private GoodsmanService goodsmanService;
	
	private CardTypeService cardTypeService;
	
	private Cardinfo cardinfo;
	
	private String cardno;
	
	private File file;
	
	private PagerModel pm;
	
	private List<Datadict> datadictByBasetypelist;
	
	private List<Datadict> datadictByAreatypelist;
	
	private List<Datadict> datadictByFuntypelist;
	
	private List<Datadict> datadictByStatuslist;
	
	private List<Department> departmentlist;
	
	private List<Design> designlist;
	
	private List<Cardmake> cardmakelist;
	
	private List<Cardmaker> cardmakerlist;
	
	private List<Cardstuff> cardstufflist;
	
	private List<Goodsman> goodsmanlist;
	
	private List<Cardsubtype> cardsubtypelist;
	
	private long datadictByBasetypeid;
	
	private long datadictByAreatypeid;
	
	private long datadictByFuntypeid;
	
	private long datadictByStatustypeid;
	
	private String deptcode;
	
	private long cardsubtypeno;
	
	private long money;
	
	@SuppressWarnings("unchecked")
	public void prepare() throws Exception {
		datadictByBasetypelist = dictService.findDictDetail(StringToken.DICT_CARD_BASETYPE);
		datadictByAreatypelist = dictService.findDictDetail(StringToken.DICT_CARD_AREATYPE);
		datadictByFuntypelist = dictService.findDictDetail(StringToken.DICT_CARD_FUNTYPE);
		datadictByStatuslist =  dictService.findDictDetail(StringToken.DICT_CARD_STATUS);
		departmentlist = departmentService.findAllleafDepartment(); 
		cardsubtypelist = cardTypeService.findAllCardsubtype();
	}
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	public String goAddCardinfo() throws Exception {
		return SUCCESS;
	}
	
	public String addCardinfo() throws Exception {
		cardinfoService.addCardinfo(cardinfo);
		return SUCCESS;
	}
	
	public String goUploadCardinfoExcel() throws Exception {
		return SUCCESS;
	}
	
	public String addCardinfoFromExcel() throws Exception {
		cardinfoService.addCardinfoFromExcel(file);
		return SUCCESS;
	}
	
	public String findAllCardinfo() throws Exception {
		pm = cardinfoService.findCardinfoForPager();
		return SUCCESS;
	}
	
	public String findCardinfoForPagerWith() throws Exception {
		pm = cardinfoService.findCardinfoForPagerWith(datadictByBasetypeid, datadictByAreatypeid, datadictByFuntypeid, datadictByStatustypeid, money, cardsubtypeno, deptcode);
		return SUCCESS;
	}
	
	public String findCardinfo() throws Exception {
		cardinfo = cardinfoService.findCardinfo(cardno);
		System.out.println(cardinfo.getCardid());
		System.out.println(cardinfo.getDepartment().getDeptcaption());
		return SUCCESS;
	}
	
	public String delCardinfo() throws Exception {
		cardinfoService.removeCardinfo(cardno);
		return SUCCESS;
	}
	
	public String getCardinfoForUpdate() throws Exception {
		cardinfo = cardinfoService.findCardinfo(cardno);
		return SUCCESS;
	}
	
	public String updateCardinfo() throws Exception {
		cardinfoService.updateCardinfo(cardinfo);
		return SUCCESS;
	}

	/**
	 * @return the cardinfo
	 */
	public Cardinfo getCardinfo() {
		return cardinfo;
	}

	/**
	 * @param cardinfo the cardinfo to set
	 */
	public void setCardinfo(Cardinfo cardinfo) {
		this.cardinfo = cardinfo;
	}

	/**
	 * @return the cardinfoService
	 */
	public CardinfoService getCardinfoService() {
		return cardinfoService;
	}

	/**
	 * @param cardinfoService the cardinfoService to set
	 */
	public void setCardinfoService(CardinfoService cardinfoService) {
		this.cardinfoService = cardinfoService;
	}

	/**
	 * @return the cardmakelist
	 */
	public List<Cardmake> getCardmakelist() {
		return cardmakelist;
	}

	/**
	 * @param cardmakelist the cardmakelist to set
	 */
	public void setCardmakelist(List<Cardmake> cardmakelist) {
		this.cardmakelist = cardmakelist;
	}

	/**
	 * @return the cardmakerlist
	 */
	public List<Cardmaker> getCardmakerlist() {
		return cardmakerlist;
	}

	/**
	 * @param cardmakerlist the cardmakerlist to set
	 */
	public void setCardmakerlist(List<Cardmaker> cardmakerlist) {
		this.cardmakerlist = cardmakerlist;
	}

	/**
	 * @return the cardmakerService
	 */
	public CardmakerService getCardmakerService() {
		return cardmakerService;
	}

	/**
	 * @param cardmakerService the cardmakerService to set
	 */
	public void setCardmakerService(CardmakerService cardmakerService) {
		this.cardmakerService = cardmakerService;
	}

	/**
	 * @return the cardmakeService
	 */
	public CardmakeService getCardmakeService() {
		return cardmakeService;
	}

	/**
	 * @param cardmakeService the cardmakeService to set
	 */
	public void setCardmakeService(CardmakeService cardmakeService) {
		this.cardmakeService = cardmakeService;
	}

	/**
	 * @return the cardno
	 */
	public String getCardno() {
		return cardno;
	}

	/**
	 * @param cardno the cardno to set
	 */
	public void setCardno(String cardno) {
		this.cardno = cardno;
	}

	/**
	 * @return the cardstufflist
	 */
	public List<Cardstuff> getCardstufflist() {
		return cardstufflist;
	}

	/**
	 * @param cardstufflist the cardstufflist to set
	 */
	public void setCardstufflist(List<Cardstuff> cardstufflist) {
		this.cardstufflist = cardstufflist;
	}

	/**
	 * @return the cardstuffService
	 */
	public CardstuffService getCardstuffService() {
		return cardstuffService;
	}

	/**
	 * @param cardstuffService the cardstuffService to set
	 */
	public void setCardstuffService(CardstuffService cardstuffService) {
		this.cardstuffService = cardstuffService;
	}

	/**
	 * @return the datadictByAreatypelist
	 */
	public List<Datadict> getDatadictByAreatypelist() {
		return datadictByAreatypelist;
	}

	/**
	 * @param datadictByAreatypelist the datadictByAreatypelist to set
	 */
	public void setDatadictByAreatypelist(List<Datadict> datadictByAreatypelist) {
		this.datadictByAreatypelist = datadictByAreatypelist;
	}

	/**
	 * @return the datadictByBasetypelist
	 */
	public List<Datadict> getDatadictByBasetypelist() {
		return datadictByBasetypelist;
	}

	/**
	 * @param datadictByBasetypelist the datadictByBasetypelist to set
	 */
	public void setDatadictByBasetypelist(List<Datadict> datadictByBasetypelist) {
		this.datadictByBasetypelist = datadictByBasetypelist;
	}

	/**
	 * @return the datadictByFuntypelist
	 */
	public List<Datadict> getDatadictByFuntypelist() {
		return datadictByFuntypelist;
	}

	/**
	 * @param datadictByFuntypelist the datadictByFuntypelist to set
	 */
	public void setDatadictByFuntypelist(List<Datadict> datadictByFuntypelist) {
		this.datadictByFuntypelist = datadictByFuntypelist;
	}

	/**
	 * @return the datadictByStatuslist
	 */
	public List<Datadict> getDatadictByStatuslist() {
		return datadictByStatuslist;
	}

	/**
	 * @param datadictByStatuslist the datadictByStatuslist to set
	 */
	public void setDatadictByStatuslist(List<Datadict> datadictByStatuslist) {
		this.datadictByStatuslist = datadictByStatuslist;
	}

	/**
	 * @return the departmentlist
	 */
	public List<Department> getDepartmentlist() {
		return departmentlist;
	}

	/**
	 * @param departmentlist the departmentlist to set
	 */
	public void setDepartmentlist(List<Department> departmentlist) {
		this.departmentlist = departmentlist;
	}

	/**
	 * @return the departmentService
	 */
	public DepartmentService getDepartmentService() {
		return departmentService;
	}

	/**
	 * @param departmentService the departmentService to set
	 */
	public void setDepartmentService(DepartmentService departmentService) {
		this.departmentService = departmentService;
	}

	/**
	 * @return the designlist
	 */
	public List<Design> getDesignlist() {
		return designlist;
	}

	/**
	 * @param designlist the designlist to set
	 */
	public void setDesignlist(List<Design> designlist) {
		this.designlist = designlist;
	}

	/**
	 * @return the designService
	 */
	public DesignService getDesignService() {
		return designService;
	}

	/**
	 * @param designService the designService to set
	 */
	public void setDesignService(DesignService designService) {
		this.designService = designService;
	}

	/**
	 * @return the dictService
	 */
	public DictService getDictService() {
		return dictService;
	}

	/**
	 * @param dictService the dictService to set
	 */
	public void setDictService(DictService dictService) {
		this.dictService = dictService;
	}

	/**
	 * @return the goodsmanlist
	 */
	public List<Goodsman> getGoodsmanlist() {
		return goodsmanlist;
	}

	/**
	 * @param goodsmanlist the goodsmanlist to set
	 */
	public void setGoodsmanlist(List<Goodsman> goodsmanlist) {
		this.goodsmanlist = goodsmanlist;
	}

	/**
	 * @return the goodsmanService
	 */
	public GoodsmanService getGoodsmanService() {
		return goodsmanService;
	}

	/**
	 * @param goodsmanService the goodsmanService to set
	 */
	public void setGoodsmanService(GoodsmanService goodsmanService) {
		this.goodsmanService = goodsmanService;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	/**
	 * @return the file
	 */
	public File getFile() {
		return file;
	}

	/**
	 * @param file the file to set
	 */
	public void setFile(File file) {
		this.file = file;
	}

	public List<Cardsubtype> getCardsubtypelist() {
		return cardsubtypelist;
	}

	public void setCardsubtypelist(List<Cardsubtype> cardsubtypelist) {
		this.cardsubtypelist = cardsubtypelist;
	}

	public CardTypeService getCardTypeService() {
		return cardTypeService;
	}

	public void setCardTypeService(CardTypeService cardTypeService) {
		this.cardTypeService = cardTypeService;
	}

	public long getMoney() {
		return money;
	}

	public void setMoney(long money) {
		this.money = money;
	}

	public long getCardsubtypeno() {
		return cardsubtypeno;
	}

	public void setCardsubtypeno(long cardsubtypeno) {
		this.cardsubtypeno = cardsubtypeno;
	}

	public long getDatadictByAreatypeid() {
		return datadictByAreatypeid;
	}

	public void setDatadictByAreatypeid(long datadictByAreatypeid) {
		this.datadictByAreatypeid = datadictByAreatypeid;
	}

	public long getDatadictByBasetypeid() {
		return datadictByBasetypeid;
	}

	public void setDatadictByBasetypeid(long datadictByBasetypeid) {
		this.datadictByBasetypeid = datadictByBasetypeid;
	}

	public long getDatadictByFuntypeid() {
		return datadictByFuntypeid;
	}

	public void setDatadictByFuntypeid(long datadictByFuntypeid) {
		this.datadictByFuntypeid = datadictByFuntypeid;
	}

	public long getDatadictByStatustypeid() {
		return datadictByStatustypeid;
	}

	public void setDatadictByStatustypeid(long datadictByStatustypeid) {
		this.datadictByStatustypeid = datadictByStatustypeid;
	}

	public String getDeptcode() {
		return deptcode;
	}

	public void setDeptcode(String deptcode) {
		this.deptcode = deptcode;
	}
	
}
